//
//  NSThreadViewController.m
//  learn-thread
//
//  Created by srxboys on 2021/4/22.
//

#import "NSThreadViewController.h"

#import "NSThread01.h"
#import "NSThreadApi.h"

@interface NSThreadViewController ()

@end

@implementation NSThreadViewController

- (void)viewDidLoad {
    [super viewDidLoad];

#define SC(_class) RX_STRING_FORMAT(@"%@", @#_class)

    [self addModelWidth:SC(NSThread01) desc:@"基本线程"];
    [self addModelWidth:SC(NSThreadApi) desc:@"NSThread api"];
    [self.tableView reloadData];
}

- (void)cellDidSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    NSInteger row = indexPath.row;
    CellModel * model = self.sourceArray[row];
    NSString * classString = model.title;
    Class className = NSClassFromString(classString);

    id objc = RXCREATE_ALLOC_STR(className);
//    id objc = RXCREATE_ALLOC(classString);

    if ([objc respondsToSelector:@selector(run)]) {
        [objc run];
    } else {
        RXLogError(@"写的有问题？");
    }
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
